
package protocol.meta;

import org.json.JSONException;
import org.json.JSONObject;

import Utils.XoneUtil;

public class BindAccountRawInfo {

    public int ver;
    public String uid;
    public String nickname;
    public String image_url;
    public String token_secret;
    public String profile_url;
    public String token;

    public BindAccountRawInfo(JSONObject json) {
        parseJson(json);
    }

    public void parseJson(JSONObject json) {
        if (json == null)
            return;

        ver = json.optInt("ver");
        uid = XoneUtil.nullStr(json.optString("uid"));
        nickname = XoneUtil.nullStr(json.optString("nickname"));
        image_url = XoneUtil.nullStr(json.optString("image_url"));
        token_secret = XoneUtil.nullStr(json.optString("token_secret"));
        profile_url = XoneUtil.nullStr(json.optString("profile_url"));
        token = XoneUtil.nullStr(json.optString("token"));
    }

    @Override
    public String toString() {
        JSONObject json = new JSONObject();
        try {
            json.put("uid", uid);
            json.put("nickname", nickname);
            json.put("image_url", image_url);
            json.put("token_secret", token_secret);
            json.put("profile_url", profile_url);
            json.put("token", token);
            json.put("ver", ver);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return json.toString();
    }

}
